<?
class User_Func{
    public function getFullname($user_id){
	    $sql = "select f.prefix_name,u.user_fname,u.user_lname 
		           from tb_user u,tb_prefix f where user_id = '$user_id' and f.prefix_id=u.prefix_id ";

		$result = mysql_query($sql)or die(mysql_error());
		$fetch = mysql_fetch_object($result);
		 return $fetch->prefix_name.$fetch->user_fname." &nbsp; ".$fetch->user_lname;
	}
	
	public function getAddress_using($user_id,$lang){
	    $sql = "select * from tb_address where user_id = '$user_id' ";
		$result = mysql_query($sql)or die(mysql_error());
		$fetch = mysql_fetch_array($result);
		list($id,$msg) = $fetch;
		
		return $msg;
	}
	
	public function getAddress($addr_id,$lang){
	    $sql = "select * from tb_address where addr_id = '$addr_id' ";
		$result = mysql_query($sql)or die(mysql_error());
		$fetch = mysql_fetch_array($result);
		list($id,$msg) = $fetch;
		
		return $msg;
	}
	
	public function getProvince($province){
	   $sql = "select * from tb_province where province_code = '$province' ";
		$result = mysql_query($sql)or die(mysql_error());
		$fetch = mysql_fetch_array($result);
		list($id,$name) = $fetch;
		return  "$name";
	}
	
	public function mobile_format($phone){
	   return "+66".substr($phone,1,1)."-".substr($phone,2,4)."-".substr($phone,6,4);
	}
	
	public function getUserStatus($status){
	   if($status=="Y")
	       $msg = "ใช้งานปกติ";
	   else
	       $msg = "ระงับการใช้งาน";
	   return $msg;
	}
}
?>
